﻿@using Kooboo.CMS.Common
@using Kooboo.CMS.Content.Models
@using Newtonsoft.Json
@model Kooboo.CMS.Content.Models.Schema
@{
    var isCreatingNewContentType = Html.ViewContext.RouteData.Values["action"].ToString().ToLower() == "create";
}
<input type="hidden" data-bind="value:schemaModel.TemplateBuildByMachine" />
<p class="field">
    @Html.EditorFor(m => m.IsTreeStyle, new { HtmlAttributes = new RouteValueDictionary() { { "data-bind", "checked:schemaModel.IsTreeStyle" } } })
</p>
<div class="block command">
    <input type="button" class="button" value="Create field" data-bind="click:AddNewColumn"/>
</div>
<div id="grid-field">
    <div id="grid-field-template">
        <div class="common-table">
            <table>
                <thead>
                    <tr>
                        <th class="nocheckbox"></th>
                        <th>@("Name".Localize())</th>
                        <th>@("Label".Localize())</th>
                        <th>@("Control type".Localize())</th>
                        <th>@("Summary field".Localize())</th>
                        <th>@("Content list page".Localize())</th>
                        <th>@("Order".Localize())</th>
                        <th class="action">@("Delete".Localize())</th>
                    </tr>
                </thead>
                <tbody class="ui-sortable">
                    <!-- ko foreach: schemaModel.Columns -->
                    <tr>
                        <td class="nocheckbox draggable">
                            <div>@Html.IconImage("drag")</div>
                        </td>
                        <td><a class="action" data-bind="text:Name,click:$root.EditColumn"></a></td>
                        <td data-bind="text:((Label()==''||Label()==null)?'-':Label)"></td>
                        <td data-bind="text:ControlType"></td>
                        <td>
                            <span data-bind="text:((Summarize()==''||Summarize()==null)?'-':'@("YES".Localize())')"></span>
                        </td>
                        <td>
                            <span data-bind="text:((ShowInGrid()==''||ShowInGrid()==null)?'-':'@("YES".Localize())')"></span>
                        </td>
                        <td data-bind="text:Order"></td>
                        <td class="hide order-field">
                            <input type="hidden" data-bind="value:Order" /></td>
                        <td class="action">
                            <a class="action" data-bind="click:$root.DeleteColumn">@Html.IconImage("minus small")</a>
                        </td>
                    </tr>
                    <!-- /ko -->
                </tbody>
            </table>
        </div>
    </div>
</div>
